package com.example.a28796.beautiful.zhangyuqiadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a28796.beautiful.R;
import com.example.a28796.beautiful.zhangyuqibean.MoreBean;

import org.xutils.x;

import java.util.List;

/**
 * Created by admin on 2016/8/31.
 */
public class BeautyMoreAdapter extends BaseAdapter {
    private Context mContext;
    private List<MoreBean.ObjBean.ListDataBean> mData;

    public BeautyMoreAdapter(Context mContext, List<MoreBean.ObjBean.ListDataBean> mData) {
        this.mContext = mContext;
        this.mData = mData;
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_more,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        MoreBean.ObjBean.ListDataBean listDataBean = mData.get(position);
        holder.mTextViewTitle1.setText(listDataBean.getTitle());
        holder.mTextViewTitle2.setText(listDataBean.getHospital().getHospitalName());
        holder.mTextViewTitle3.setText("已售"+listDataBean.getStockNum().getSaleNum()+"件");
        holder.mTextViewTitle4.setText("¥"+listDataBean.getSalePrice()+"元");
        holder.mTextViewTitle5.setText("¥"+listDataBean.getOrigPriceMax());
        x.image().bind(holder.mImageView,listDataBean.getCover().getUrl());
        return convertView;
    }

    private static class ViewHolder {
        private ImageView mImageView;
        private TextView mTextViewTitle1,mTextViewTitle2,mTextViewTitle3,mTextViewTitle4,mTextViewTitle5;
        public ViewHolder(View view){
        mImageView = (ImageView) view.findViewById(R.id.iv_more_show);
            mTextViewTitle1 = (TextView) view.findViewById(R.id.tv_more_title1);
            mTextViewTitle2 = (TextView) view.findViewById(R.id.tv_more_title2);
            mTextViewTitle3 = (TextView) view.findViewById(R.id.tv_more_title3);
            mTextViewTitle4 = (TextView) view.findViewById(R.id.tv_more_title4);
            mTextViewTitle5 = (TextView) view.findViewById(R.id.tv_more_title5);
        }
    }
}
